<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/validation.jsp"%>
<%@ include file="/commons/dateTime.jsp"%>
<%@ include file="/commons/fileUpload.jsp" %>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript">

   function showLayer(){

		if (!document.getElementById("cb1").checked){
			document.getElementById("layer").style.display="none";
			document.getElementById("hasCell").value="0";
			Validation.changeElmValidate("cellCount","");
		} else {
			document.getElementById("layer").style.display="";
			Validation.changeElmValidate("cellCount","required int-range-1-10");
			document.getElementById("hasCell").value="1";

		}

		if("${buildingVO.permitModifyCell}"=='false'){
		document.getElementById("cb1").disabled=true;
       }
   }

   function getValidationFloorCallBack(respose){
   if(respose.responseText!='true'){

      validationAlert("validationFloor",true,"该楼栋"+respose.responseText+"层已经有房间");
     return false;
   }else{
     validationAlert("validationFloor",false,"");
   }

       document.getElementById("home").value=$F("homeFrom")+","+$F("homeTo");
        document.getElementById("home").value=$F("home").replace(/[ ]/g,"");
		document.getElementById("shop").value=$F("shopFrom")+","+$F("shopTo");
		 document.getElementById("shop").value=$F("shop").replace(/[ ]/g,"");
		document.getElementById("carbarn").value=$F("carbarnFrom")+","+$F("carbarnTo");
		 document.getElementById("carbarn").value=$F("carbarn").replace(/[ ]/g,"");
		 if(document.getElementById("carbarn").value.length==1)document.getElementById("carbarn").value='';
		 if(document.getElementById("shop").value.length==1)document.getElementById("shop").value='';

		$("editBuildingForm").submit();
   }


   function submitForm(){

     var isTrue=$("editBuildingForm").fireEvent("onSubmit");

	  if(isTrue){
        var keyword=document.getElementById("keyword").value;
        var homeFrom=$F("homeFrom").replace(/[ ]/g,"");
        var homeTo=$F("homeTo").replace(/[ ]/g,"");
        var url="${ctx}/house_buildingAction.do?method=validationFloor";
        var pars="keyword="+keyword+"&homeFrom="+homeFrom+"&homeTo="+homeTo;

         var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars, onComplete: getValidationFloorCallBack}
		                    );
	   }

  }

  function setFormTOData(){
    var homeValue = document.getElementById("home").value;
    var shopValue = document.getElementById("shop").value;
    var carbarnValue = document.getElementById("carbarn").value;
     if(homeValue.indexOf(",")!=-1){
       document.getElementById("homeFrom").value=homeValue.substring(0,homeValue.indexOf(","));
       document.getElementById("homeTo").value=homeValue.substring(homeValue.indexOf(",")+1,homeValue.length);
     }

     if(shopValue.indexOf(",")!=-1){
       document.getElementById("shopFrom").value=shopValue.substring(0,shopValue.indexOf(","));
       document.getElementById("shopTo").value=shopValue.substring(shopValue.indexOf(",")+1,shopValue.length);
     }

     if(carbarnValue.indexOf(",")!=-1){
       document.getElementById("carbarnFrom").value=carbarnValue.substring(0,carbarnValue.indexOf(","));
       document.getElementById("carbarnTo").value=carbarnValue.substring(carbarnValue.indexOf(",")+1,carbarnValue.length);
     }

  }

  function getSeqNO(){

   if($F("projectId")==''){

   document.getElementById("seqNo").value="";
    return false;
   }

  var url="${ctx}/house_buildingAction.do?method=generationMaxSeqNoByProjectId";
  var pars="projectId="+$F("projectId");

    var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars, onComplete: getCallBack}
		                    );
  }

  function getCallBack(respose){

     document.getElementById("seqNo").value=respose.responseText;
  }

</script>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"> <span class="window_head_intext">修改楼栋</span></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td valign="middle" class="content"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="container_in_show">
      <tr>
        <td valign="top">
            <div id="tab_Search" style="height:250px;">
             <form id="editBuildingForm" name="editBuildingForm" method="post" action="${ctx}/house_buildingAction.do?method=editBuilding" class="required-validate" ENCTYPE="multipart/form-data">
              <input type="hidden" name="areaId" value="${buildingVO.areaId}">
               <input type="hidden" name="keyword" value="${buildingVO.keyword}">
                <input type="hidden" name="hasCell" value="${buildingVO.hasCell}">
              <table width="100%" border="0" cellpadding="0" cellspacing="0" id="tab_subMenu1">
                <tr>
                  <td><table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">

                      <tr>
                        <td>

						<table width="100%" border="0" align="center" cellpadding="5" cellspacing="1"  class="aux_intable_color">
                    <tr>
                      <td class="aux_intable_td41">楼盘：</td>
                      <td class="aux_intable_td42">${buildingVO.areaName}</td>
                      <td class="aux_intable_td41">商铺层：<input type="hidden" name="shop" value="${buildingVO.shop}"></td>
                      <td colspan="2" class="aux_intable_td42">从第
                        <input name="shopFrom" type="text" maxLength="14" class="validate-integer less-equals-than-shopTo" validateMessageLessThan="不能大于后面的值" style="text-align:right" value="" size="4">
                        到
  <input name="shopTo" type="text" maxLength="14" class="validate-integer great-equals-than-shopFrom" style="text-align:right" value="" size="4"></td>
                    </tr>
                    <tr>
                      <td class="aux_intable_td41">期数：</td>
                      <c:if test="${hasMoreProject==1}"><!-- 分期 -->
                      <td class="aux_intable_require">
                      <pms:unitedSelect id="projectId"
                                              selectText="请选择..."
											name="projectId"
											dataList="${projectList}"
											optionLabel="name"
											className="select-one-required"
											optionValue="keyword"
											onChange="getSeqNO();"
											value="${buildingVO.projectId}">
						</pms:unitedSelect>
						</c:if>
						<c:if test="${hasMoreProject==0}"><!-- 不分期 -->
                        <td class="aux_intable_td42">
						<input type="hidden" name="projectId" value="${buildingVO.projectId}">
						</c:if>

                      </td>
                      <td class="aux_intable_td41">建筑面积：</td>
                      <td colspan="2" class="aux_intable_td42"><input name="buildSize" maxLength="12" type="text" class="float-right integer-decimal-range-12-2" value="${buildingVO.buildSize}" afterInsert="buildSizeSpan" style="text-align:right" size="16">
                        ㎡<span id="buildSizeSpan"></span></td>
                    </tr>
                    <tr>
                      <td class="aux_intable_td41">楼栋名称：</td>
                      <td class="aux_intable_require"><input name="name" type="text" maxLength="80" class="required validate-char validate-ajax" relativeId="areaId,keyword" validateUrl="${ctx}/house_buildingAction.do?method=checkNameIsExist" value="${buildingVO.name}" size="16"></td>
                      <td class="aux_intable_td41">耐火等级：</td>
                      <td colspan="2" class="aux_intable_td42">
                      <pms:unitedSelect id="fireproofLevelId"
                                              selectText="请选择..."
											name="fireproofLevelId"
											dataList="${fireproofingLevelList}"
											optionLabel="name"
											optionValue="id"
											value="${buildingVO.fireproofLevelId}">
						</pms:unitedSelect></td>
                    </tr>
                    <tr>
                      <td class="aux_intable_td41">楼栋编号：</td>
                      <td class="aux_intable_require"><input name="seqNo" type="text" class="required int-right validate-ajax" relativeId="projectId,keyword" validateUrl="${ctx}/house_buildingAction.do?method=editCheckSeqNoIsExist" value="${buildingVO.seqNo}" size="16"></td>
                      <td class="aux_intable_td41">抗震设防烈度：</td>
                      <td colspan="2" class="aux_intable_td42">
                      <pms:unitedSelect id="aseismeticLevelId"
                                              selectText="请选择..."
											name="aseismeticLevelId"
											dataList="${quakeproofLevelList}"
											optionLabel="name"
											optionValue="id"
											value="${buildingVO.aseismeticLevelId}">
						</pms:unitedSelect></td>
                    </tr>
                    <tr>
                      <td class="aux_intable_td41">地上层数：</td>
                      <td class="aux_intable_require"><input name="overGround" type="text" class="required int-right" value="${buildingVO.overGround}" style="text-align:right" size="16"></td>
                      <td class="aux_intable_td41">人防防护等级：</td>
                      <td colspan="2" class="aux_intable_td42">
                      <pms:unitedSelect id="aerialDefenceLevelId"
                                              selectText="请选择..."
											name="aerialDefenceLevelId"
											dataList="${personSafeguardList}"
											optionLabel="name"
											optionValue="id"
											value="${buildingVO.aerialDefenceLevelId}">
						</pms:unitedSelect></td>
                    </tr>
                    <tr>
                      <td class="aux_intable_td41">地下层数：</td>
                      <td class="aux_intable_td42"><input name="underGround" type="text" class="int-right" value="${buildingVO.underGround}" style="text-align:right" size="16"></td>
                      <td class="aux_intable_td41">主要结构选型：</td>
                      <td colspan="2" class="aux_intable_td42"><input name="framework" maxLength="50" type="text" class="inputtext validate-char" value="${buildingVO.framework}" size="16"></td>
                    </tr>
                    <tr>
                      <td class="aux_intable_td41"><input type="checkbox" name="hasCellBheckbox" value="checkbox" id="cb1" onClick="showLayer()">
                        分单元</td>
                      <td class="aux_intable_td42"><table width="171" border="0" cellspacing="0" cellpadding="0" id="layer" style="display:none">
                        <tr>
                          <td valign="top" width="45%"  class="aux_intable_require">单元数：</td>
                          <td valign="top" width="55%" align="left" ><input name="cellCount" id="cellCount" type="text" class="" style="text-align:right" value="${buildingVO.cellCount}" size="4"></td>
                        </tr>
                      </table></td>
                     <td rowspan="2" valign="top" class="aux_intable_td41">规划图：</td>
                      <td colspan="2" rowspan="2" valign="top" class="aux_intable_td42">
					     <mypms:ImageUpload name="picpath1"  maxNum="1" data="${buildingVO.layoutImageVo}" imageType="jpg,JPG,gif,GIF" postfixName="layoutImageVo">
				              </mypms:ImageUpload>
				              </td>
                    </tr>
					 <tr>
					   <td valign="top" class="aux_intable_td41">建筑总高度：</td>
					   <td valign="top" class="aux_intable_td42"><input name="high" afterInsert="highSpan" type="text" maxLength="12" class="float-right integer-decimal-range-12-2" value="${buildingVO.high}" style="text-align:right" size="16">
					   m<span id="highSpan"></span></td>

                    </tr>
					 <tr>
					   <td valign="top" class="aux_intable_td41">竣工日期：</td>
					   <td valign="top" class="aux_intable_td42"><input name="completeDate" type="text" class="validate-date" afterInsert="completeDateAfter" value="<fmt:formatDate pattern='yyyy-MM-dd' value='${buildingVO.completeDate}'/>" size="16">
					   <img id="imgCompleteDate" src="${ctx}/images/ico_clock.gif" width="20" height="20"><span id="completeDateAfter"></span></td>
                   <td rowspan="2" valign="top" class="aux_intable_td41">户型平面图：</td>
                   <td colspan="2" rowspan="2" valign="top" class="aux_intable_td42">
                     <mypms:ImageUpload name="picpath2"  maxNum="12" data="${buildingVO.ichnographys}" imageType="jpg,JPG,gif,GIF" postfixName="ichnographys">
				       </mypms:ImageUpload>
                       </td>
					   </tr>
                    <tr>
                      <td class="aux_intable_td41">区域/位置：</td>
                      <td class="aux_intable_td42"><input name="position" type="text" maxLength="200" class="inputtext validate-char" value="${buildingVO.position}" size="16"></td>

                    </tr>
					 <tr>
					   <td class="aux_intable_td41">住宅层：<input type="hidden" name="home" value="${buildingVO.home}"></td>
					   <td class="aux_intable_require">从第
					     <input name="homeFrom" maxLength="14" type="text" class="required validate-integer less-equals-than-homeTo" validateMessageLessThan="不能大于后面的值" style="text-align:right" value="" size="4">
					     到
  <input name="homeTo" type="text" class="required validate-integer great-equals-than-homeFrom less-equals-than-overGround" validateMessageLessEquals="必须小于或者等于地上层数" maxLength="14" style="text-align:right" value="" size="4"><span id="validationFloor"></span></td>
					   <td rowspan="3" valign="top" class="aux_intable_td41">备注：</td>
                       <td colspan="2" rowspan="2" valign="top" class="aux_intable_td42"><textarea maxLength="500" name="remark" cols="29" rows="4" class="textareatext">${buildingVO.remark}</textarea></td>
					 </tr>
					 <tr>
					   <td class="aux_intable_td41">车库层：<input type="hidden" name="carbarn" value="${buildingVO.carbarn}"></td>
                      <td class="aux_intable_td42">从第
                        <input name="carbarnFrom" type="text" maxLength="14" class="validate-integer less-equals-than-carbarnTo" style="text-align:right" validateMessageLessThan="不能大于后面的值" value="" size="4">
到
<input name="carbarnTo" type="text" class="validate-integer great-equals-than-carbarnFrom" maxLength="14" style="text-align:right" value="" size="4"></td>
					   </tr>

                  </table>

						</td>
                      </tr>

                  </table></td>
                </tr>
              </table>
</form>
			</div>
		  </td>
      </tr>
    </table>

	</td>
  </tr>
  <tr>
    <td class="window_footer"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0" >
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onblur="btn_change(2)" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onClick="submitForm();"><img src="${ctx}/images/ico_ok.gif" border="0" align="absmiddle" /> 保 存</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onblur="btn_change(3)" onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)"><img src="${ctx}/images/ico_cancel.gif" border="0" align="absmiddle" /> 关 闭</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>

</body>
<script type="text/javascript">
  Calendar.setup(
              {
	              inputField : "completeDate", // ID of the input field
	              ifFormat : "%Y-%m-%d", // the date format
	              button : "imgCompleteDate", // ID of the button
	              align          :    "Tl",           // alignment (defaults to "Bl")
			      singleClick    :    true
              }
              );

   setFormTOData();
   if("${buildingVO.hasCell}"==1){
   document.getElementById("cb1").checked=true;
   }
   showLayer();
   if("${buildingVO.permitModifyCell}"=='false'){
   document.getElementById("cellCount").readOnly=true;
   }

</script>
</html>